package com.company;

/**
 * @author zhf
 * @date 2021/11/26
 */

import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

/**
 * 二叉树中序遍历
 */
public class MidTravel {

    public static void main(String[] args) {
        Integer[] array = { 3,9,20,null,null,15,7 };
        TreeNode root = TreeUtil.CreateTree(array);
        MidTravel midTravel = new MidTravel();
        List<Integer> ans = new ArrayList<>();
        List<Integer> list = midTravel.inorderTraversal(root,ans);
        System.out.println(list);
    }


    public List<Integer> inorderTraversal(TreeNode root,List<Integer> list) {
        if (root == null){
            return null;
        }
        inorderTraversal(root.left,list);
        list.add(root.val);
        inorderTraversal(root.right,list);
        return list;
    }
}
